package com.ovolucky.mapmytrip.app;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class CreateMarkerActivity extends Activity {

  public static final String TITLE_KEY = "title";
  public static final String DESCRIPTION_KEY = "description";

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.create_marker);

    Button cancelButton = (Button)findViewById(R.id.cancelButton);
    cancelButton.setOnClickListener(new Button.OnClickListener(){

      @Override
      public void onClick(View v) {
        setResult(RESULT_CANCELED);
        finish();
      }});

    Button saveButton = (Button) findViewById(R.id.saveButton);
    saveButton.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
        Intent intent = getIntent();
        final String title =
            ((EditText) findViewById(R.id.titleEditText)).getText().toString();
        final String description =
            ((EditText) findViewById(R.id.desEditText)).getText().toString();
        intent.putExtra(TITLE_KEY, title);
        intent.putExtra(DESCRIPTION_KEY, description);
        setResult(RESULT_OK, intent);
        finish();
      }
    });
  }
}
